/*
 * FIR.c
 *
 *  Created on: 20-01-2013
 *      Author: Maciej
 */

#include "Comum.h"

//Warning! Not-efficient implementation!

//volatile char FIR_ON = 1;

void FIR_Init(sFIR* filter)
{
	unsigned int i;

	for (i = 0; i < FIR_SIZE; ++i)
		filter->buffer[i] = 0; //filter->coefs[i] =

}

float FIR_Get(sFIR* filter, float sample)
{
	//if (!FIR_ON) return sample;

	float ret = 0;
	unsigned int i;

	for (i = 0; i < FIR_SIZE - 1; ++i)
		filter->buffer[i] = filter->buffer[i + 1];

	filter->buffer[FIR_SIZE - 1] = sample;

	for (i = FIR_SIZE-1; i; --i)
		ret += filter->buffer[i] * (1.0 / (float) FIR_SIZE); //filter->coefs[i];

	return ret;
}

